<%@page import="helpers.SessionHelper"%>
<%@page import="models.GeoModel"%>
<%@page import="data.GeoData"%>
<%@page import="models.UserModel"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	UserModel user = (UserModel) request.getAttribute("user_logged_in");
	String activeCategory = "";
	if(request.getAttribute("activeCategory")!=null&&!request.getAttribute("activeCategory").equals("")){
		activeCategory = (String)request.getAttribute("activeCategory"); 
	}	
	String city = "ha-noi";
	if(request.getAttribute("city")!=null&&!request.getAttribute("city").equals("")){
		city = (String)request.getAttribute("city"); 
	}else{
		Cookie cookies [] = request.getCookies ();	
		if (cookies != null)
		{
			for (int i = 0; i < cookies.length; i++) 
			{
				if (cookies [i].getName().equals ("city"))
				{
					city = cookies[i].getValue();
					break;
				}
			}
		}
	}	
	GeoData geoData = new GeoData();   
	GeoModel currentGeo = SessionHelper.getCurrentCity(request);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>onsale365</title>
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link rel="stylesheet" type="text/css" href="/css/ui-lightness/jquery-ui-1.8.18.custom.css" />
<script type="text/javascript" src="/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.18.custom.min.js"></script>
<script type="text/javascript" src="/js/template.js"></script>
<script type="text/javascript" src="/js/jquery.countdown.js"></script>
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/js/login.js"></script>
<!--[if lt IE 9]>
	<body class="ie">
<![endif]-->
</head>
<body>
	<div id="master">
		<header>
			<div id="header">
                <div id="headerTop">
                    <div id="headerTop_inner">
                    	<div id="headerTopContent" class="clearafter">
                        	<div id="logo" class="left"><a href="/<%=currentGeo.getAlias()%>"><img src="/images/logo.png" alt="logo" title="logo" /></a></div>
                            <div class="left citySelect">
                            	<form method="post" action="">
                                	<input type="text" readonly="readonly" value="<%=currentGeo.getName() %>" class="cityText" />
                                    <ul class="cityListing">                                    	
                                    	<%
                                    		for(GeoModel geo: geoData.getCities()){                                   				
                                   		%>
                                    	<li onclick="window.location.href = '/<%=geo.getAlias()%>';"><%=geo.getName() %></li>
                                        <%
                                    		}
                                        %>
                                    </ul>
                                </form>
                            </div>
                            <div class="right clearafter">                            
                            	<ul class="topLogin clearafter">
	                            	<% if (user == null) { %>
	                            	<li class="userRegister"><a href="/register">Đăng ký</a></li>
	                            	<li>|</li>
	                                <li class="userLogin">
	                                	<a href="#">Đăng nhập</a>
	                                </li>	                                
	                                <% } else { %>
	                                <li class="userLogged">
	                                	<div>
	                                		<a href="javascript:return false;"><%=user.getName() %></a>
	                                		<div class="userOption">
		                                    	<div><a href="/profile">Thông tin cá nhân</a></div>
		                                        <div><a href="/quan-ly-don-hang">Đơn hàng</a></div>
		                                        <div><a href="/logout">Đăng xuất</a></div>
		                                    </div>
	                                	</div>	                                	
	                                </li>	                                
									<% } %>
	                            </ul>
	                            <% if (user == null) { %>
                                <div class="registerEmail right">
                                    <form method="post" action="/register-email" class="clearafter">
	                                	<input type="hidden" value="<%=currentGeo.getGeoId()%>" name="city"/> 
	                                	<input type="text" value="Nhận thông tin khuyến mại" name="email" />
	                                    <button type="submit">Gửi</button>
	                                </form>
                                </div>
                                <% } %>
                            </div>
                        </div>
                    </div>
                </div>                
            </div>
            <jsp:include page="/elements/list_category.jsp"/>
        </header>
        <div id="content">